<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>企业管理</h2>
    </div>

    <div class="cf">
        <div class="fl">
            <a class="btn" href="{:U('Enterprise/add')}">新 增</a>
            <button class="btn ajax-post" url="{:U('Enterprise/enable',array('method'=>'resumeUser'))}" target-form="ids">启 用</button>
            <button class="btn ajax-post" url="{:U('Enterprise/disable',array('method'=>'forbidUser'))}" target-form="ids">禁 用</button>
            <button class="btn ajax-post confirm" url="{:U('Enterprise/clear',array('method'=>'deleteUser'))}" target-form="ids">删 除</button>
        </div>

        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="keyword" class="search-input" value="{:I('keyword')}" placeholder="请输入企业名称或管理员名称">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('Enterprise/index')}"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>

    <div class="data-table table-striped">
        <table>
            <thead>
            <tr>
                <th class="row-selected">
                    <input class="checkbox check-all" type="checkbox">
                </th>
                <th>ID</th>
                <th>企业名称</th>
                <th>单位地址</th>
                <th>管理员名称</th>
                <th>管理员电话</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="list">
                <volist name="list" id="item">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="ids[]" id="" value="{$item['id']}"> </td>
                        <td>{$item.id}</td>
                        <td><a href="__URL__/edit/id/{$item.id}">{$item.name}</a></td>
                        <td>{$item.address}</td>
                        <td>{$item.admin_name}</td>
                        <td>{$item.admin_tel}</td>
                        <td> <if condition="$item.status eq 1">
                              开启
                             <else/>
                             禁用
                             </if>
                        </td>
                        <td>
                            <a title="编辑" href="__URL__/edit/id/{$item.id}">编辑</a>
                            <a class="confirm ajax-get" title="删除" href="__URL__/del/id/{$item.id}">删除</a>

                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>

    <div>
        {$page}
    </div>

</block>

<block name="script">

    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        $(function() {
            //导航高亮
            highlight_subnav("{:U('Enterprise/index')}");
            //点击排序
            $('.list_sort').click(function(){
                var url = $(this).attr('url');
                var ids = $('.ids:checked');
                var param = '';
                if(ids.length > 0){
                    var str = new Array();
                    ids.each(function(){
                        str.push($(this).val());
                    });
                    param = str.join(',');
                }

                if(url != undefined && url != ''){
                    window.location.href = url + '/ids/' + param;
                }
            });
            


            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
                query = query.replace(/^&/g,'');
                if( url.indexOf('?')>0 ){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e){
                if(e.keyCode === 13){
                    $("#search").click();
                    return false;
                }
            });

        });

    </script>
</block>